package edu.towson.cis.cosc603.project4.vendingmachine;

import static org.junit.Assert.*;
import org.junit.*;


public class VendingMachineItemTEST {

        VendingMachineItem item1;  //Normal item
        VendingMachineItem item2; //For testing item without Name.
        VendingMachineItem item3; //For testing item with wrong type of price.
        VendingMachineItem item4; //For testing item with negative price.
        
        /**
         * @throws java.lang.Exception
         */
        @BeforeClass
        public static void setUpBeforeClass() throws Exception {
        } 

        /**
         * @throws java.lang.Exception
         */
        @AfterClass
        public static void tearDownAfterClass() throws Exception {
        }

        /**
         * @throws java.lang.Exception
         */
        @Before
        
        public void setUp() throws Exception {
                item1 = new VendingMachineItem("KitKat",1.0);
                item2 = new VendingMachineItem("", 1.0);
                item3 = new VendingMachineItem("Lays", 1);
//                item4 = new VendingMachineItem("Snyder's", -1.0);
                
        }
        
        @Test
        public void testVendingMachineItem(){   
                assertEquals("KitKat", item1.getName()); 
                assertEquals(1.0, item1.getPrice(), 0); 
                assertEquals("",item2.getName()); 
                assertEquals(1.0, item2.getPrice(), 0);
                assertEquals("Lays",item3.getName()); 
                assertEquals(1, item3.getPrice(), 0);
                assertEquals("Snyder's",item4.getName()); 
                assertEquals(-1.0, item4.getPrice(), 0);
        
        }
                
        @Test
        public void testGetName(){
                assertEquals("KitKat", item1.getName()); 
                assertEquals("",item2.getName());  
        }
        
        @Test
        public void testGetPrice(){
                assertEquals(1.0 , item1.getPrice(), 0); 
                assertEquals(1, item3.getPrice(), 0);
                assertEquals(-1, item4.getPrice(), 0);
        }        

        @Test (expected = VendingMachineException.class)
        public void testVendingMachineItemException(){
        	item4 = new VendingMachineItem("Snyder's", -1.0);  //For testing this program handle exception for negative price. 
        }

        /**
         * @throws java.lang.Exception
         */
        @After
        public void tearDown() throws Exception {
        }

}